layui.config({
    base: "/layui/"
}).extend({
    index: 'lib/index'
}).use(['index', 'form', 'jquery', 'upload', 'table'], function () {
    var form = layui.form,
        table = layui.table,
        upload = layui.upload,
        admin = layui.admin;
    var apply = false;
    form.render();
    form.verify({
        FinalRate: function (value) {

            if (value<0||value>0.6) {
                return '微信结算费率设置不合理';
            }
        },
        SubsidyRate: function (value) {
            if (value<0||value>0.2) {
                //小于0.2
                    return '补贴设置不合理';
            }
        }
    });

    /**
     * 微信支付资料提交
     */
    form.on('submit(enterprise_form_wx_ok)', function (data) {
        layer.confirm("确认提交微信支付资料吗，保存后不能更改了", {
            btn: ["确认", "取消"]
        }, function (index, layero) {
            $.ajax({
                url: "/enterprise_info/edit",
                data: data.field,
                type: "post",
                success: function (result) {
                    if (result.code == 1) {
                        layer.msg("编辑成功", {
                            offset: '32%'
                            , icon: 1
                            , time: 0
                            , btn: '知道了'
                            , btnAlign: "c"
                            , shade: 0.4
                            , yes: function () {
                                layer.closeAll();
                            }
                        })
                    } else {
                        layer.msg(result.message, {
                            offset: '32%'
                            , icon: 2
                            , time: 3000
                        }, function () {
                            layer.closeAll();
                        })
                    }
                }
            });
        }, function (index) {

        });

        return false;
    });

    form.on('submit(enterprise_form_ali_ok)', function (data) {
        layer.confirm("确认提交支付宝资料吗，保存后不能更改了", {
            btn: ["确认", "取消"]
        }, function (index, layero) {
            $.ajax({
                url: "/enterprise_info/edit",
                data: data.field,
                type: "post",
                success: function (result) {
                    if (result.code == 1) {
                        layer.msg("编辑成功", {
                            offset: '32%'
                            , icon: 1
                            , time: 0
                            , btn: '知道了'
                            , btnAlign: "c"
                            , shade: 0.4
                            , yes: function () {
                                layer.closeAll();
                            }
                        })
                    } else {
                        layer.msg(result.message, {
                            offset: '32%'
                            , icon: 2
                            , time: 3000
                        }, function () {
                            layer.closeAll();
                        })
                    }
                }
            });
        }, function (index) {

        });

        return false;
    });


   $("#auth_btn").click(function () {
       var aliCallBackUrl = $("#aliCallBackUrl").val();
       $("#authqr").empty()
       $("#authqr").qrcode({
           render: "canvas", //也可以替换为table
           width: 200,
           height: 200,
           text: aliCallBackUrl
       });

       layer.open({
           type: 1,
           shade: 0.6,
           title: '支付宝授权二维码',
           shadeClose:true,
           resize:false,
           area: ['300px', '300px'],
           content:$(".face_qr")
       });
   });




});





